<template>
	<div>
		<el-form ref="form" :model="form" :rules="rules"  label-width="80px">
			<el-form-item label="护理级别id" prop="nurseLevelId" label-width="90px">
				<!-- <el-input v-model="form.nurseLevelId"></el-input> -->
			<template>
			  <el-select v-model="value" placeholder="请选择">
			    <el-option
			      v-for="item in options"
			      :key="item.value"
			      :label="item.label"
			      :value="item.value">
			    </el-option>
			  </el-select>
			</template>
			</el-form-item>

			<el-form-item label="护理内容" prop="nurseContent">
				<el-input v-model="form.nurseContent"></el-input>
			</el-form-item>
			
			<el-form-item label="护理周期" prop="careCycle">
				<el-input v-model="form.careCycle"></el-input>
			</el-form-item>
			
			<el-form-item label="执行次数" prop="nurseNumber">
				<el-input v-model="form.nurseNumber"></el-input>
			</el-form-item>
			
			<el-form-item label="备注" prop="note">
				<el-input v-model="form.note"></el-input>
			</el-form-item>

			<el-form-item>
				<el-button type="primary" plain @click="save">保存数据</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	import axios from '@/utils/axiosutils.js';
	export default {
		name: 'nurseLevelcontentAdd',
		props: ['editid'],
		components: {},
		data() {
			return {
				options: [{
				          value: '选项1',
				          label: '一级'
				        }, {
				          value: '选项2',
				          label: '二级'
				        }, {
				          value: '选项3',
				          label: '三级'
				        }],
						 value: '',
					
				form: {
					nurseLevelId: '',
					nurseContent: '',
					careCycle: '',
					nurseNumber: ''
				},
				rules:{
					nurseLevelId:[{required: true, message: '请输入', trigger: 'blur'}],
					nurseContent:[{required: true, message: '请输入', trigger: 'blur'}],
					careCycle:[{required: true, message: '请输入', trigger: 'blur'}],
					nurseNumber:[{required: true, message: '请输入', trigger: 'blur'}],
				},
			};
		},
		created() {
			if (this.editid) {
				// 如果是修改 用户名输入框禁用
				this.isupdate = true;
				axios.get(
					'/nurseLevelContent/getById',
					response => {
						this.form.id = this.editid;
						this.form.nurseLevelId = response.obj.nurseLevelId;
						this.form.nurseContent = response.obj.nurseContent;
						this.form.careCycle = response.obj.careCycle;
						this.form.nurseNumber = response.obj.nurseNumber;
						this.form.note = response.obj.note;
						
					}, {
						id: this.editid
					}
				);
			}
		},
		methods: {
			save: function() {
				if (this.editid) {
					axios.post(
						'/nurseLevelContent/update',
						resp => {
							this.$emit('update:show', false);
							this.$emit('getData');
						},
						this.form
					);
				} else {
					axios.post(
						'/nurseLevelContent/add',
						resp => {
							this.$emit('update:show', false);
							this.$emit('getData');
						},
						this.form
					);
				}
			}
		}
	};
</script>

<style></style>
